import React, { Component } from 'react';

class Time extends Component {

    /**
     * 获取指定的时间
     * @param type 类型:day(2017-02-28) h(11:35)
     */
    getTimes(type = 'day') {
        let time = this.props.time;
        let pos = time.indexOf(' '); //空格的位置
        return type === 'day' ? time.substr(0, pos) : time.substr(pos + 1, 5)
    }
    render() {
        console.log(this.getTimes())
        return (
            <div>
                这里是其他组件
            </div>
        );
    }
}

Time.defaultProps = {
    time: '2017-02-28 11:33:00',
}

export default Time;